<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DOM操作</title>
</head>
<body>

<form action="" method="post">
    <label for="username">用户名：</label>
    <input id="username" type="text" name="username" placeholder="请输入用户名">
    <label for="pwd">密 码：</label><input id="pwd" type="password" name="pwd" placeholder="请输入密码"><br>
    <input type="button" value="登录" onclick="login();">
</form>
<script type="text/javascript">
    let num = 132;
    function login(){
        let uname = 'HalfQ';
        let password = "123456";
        let ele = document.getElementById("username");
        let username = ele.value;
        console.log("用户名："+username);
        let pwd = document.getElementById("pwd").value;
        console.log("密码："+pwd);
        let res = (username===uname && pwd===password)?'用户登录成功':'用户登录失败';
        document.write(res);
    }
</script>

</body>
</html>